<template>
  <div>
    <MainNavBar>
      <template #center-name> 成绩查询 </template>
    </MainNavBar>
    <div class="content_C">
      <div class="content">
        <div class="top">
          <div class="top_l">
            <div class="circular"></div>
            <div class="line"></div>
          </div>
          <div class="top_r">参赛运动员证件信息</div>
        </div>
        <div class="user_info">
          <div class="ipt" @click="showPicker = true">
            <!-- <div >{{value}}</div> -->
            <div class="value">{{ value }}</div>
            <img
              src="http://qnticao.laigl.com/vue/pullingDown2.png"
              v-if="showPicker"
              alt=""
            />
            <img src="http://qnticao.laigl.com/vue/pullingDown1.png" v-else alt="" />
          </div>
          <van-popup v-model:show="showPicker" round position="bottom">
            <van-picker
              title="请选择证件类型"
              :columns="columns"
              @cancel="showPicker = false"
              @confirm="onConfirm"
            />
          </van-popup>
          <div class="user_card">
            <input type="text" v-model="idcard" placeholder="请填写证件号" />
          </div>
        </div>
        <div class="bot" @click="getScore">
          <img src="http://qnticao.laigl.com/vue/Scoreinquiry.png" alt="" />
          <div>点击查询</div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import MainNavBar from "@/components/common/nav/MainNavBar.vue";
import { Toast } from 'vant';
import {request} from '../../network/request'
export default {
  data() {
    return {
      showPicker: false,
      columns: ["第二代居民身份证","护照", "港澳台通行证","出生证"],
      flag: false,
      idcard:null,
      value:"第二代居民身份证"
    };
  },
  methods: {
    onConfirm(value,index) {
      this.value = value;
      this.showPicker = false;
      this.flag = true;
    },
    getScore(){
        // let _IDRe15 =  /^([1-6][1-9]|50)\d{4}\d{2}((0[1-9])|10|11|12)(([0-2][1-9])|10|20|30|31)\d{3}$/
        // let _IDRe18 =  /^([1-6][1-9]|50)\d{4}(18|19|20)\d{2}((0[1-9])|10|11|12)(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/
        // let patternTaiwan = /^[a-zA-Z][0-9]{9}$/;//台湾
        // let patternMacao = /^[1|5|7][0-9]{6}\([0-9Aa]\)/
        const rules = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/;
        if(!this.value){
            Toast("请先选择证件类型")
            return
        }
        if(!rules.test(this.idcard) && this.value==this.columns[0]){
            Toast("请填写正确的证件号")
            return
        };    
        this.$router.push({
            name:'score',
            params:{
                idcard:this.idcard
            }
        })   
    },
     print(){
      let iframe = document.querySelector("#iframe");
      // let iwindow = iframe.contentWindow;
      let idocument = iframe.contentDocument;
      // iframe.contentWindow.focus();
    iframe.contentWindow.print();
      // console.log(iframe);
      // console.log(idocument);
      // console.log(idocument.document);
      // console.log(idocument.contentDocument);
      // idocument.document.execCommand("print")
      // idocument.print()
      // idocument.document.execCommand("print")
    }
  },
  components: {
    MainNavBar,
  },
};
</script>

<style lang="less" scoped>
.content {
  width: 88vw;
  height: 26.667vw;
  margin: 0 auto;
  margin-top: 8vw;
  .top {
    display: flex;
    .top_l {
      width: 8.533vw;
      margin-left: 2.667vw;
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;
      padding-top: 2.133vw;
      .circular {
        width: 3.2vw;
        height: 3.2vw;
        border: solid 0.533vw #fff;
        border-radius: 2.133vw;
      }
      .line {
        height: 5.6vw;
        width: 0.533vw;
        background-color: #fff;
      }
    }
    .top_r {
      color: rgba(255, 255, 255, 1);
      font-size: 4.8vw;
      //   font-weight: 600;
      letter-spacing: 0.267vw;
      font-family: PingFangSC-Regular;
      line-height: 8.533vw;
    }
  }
  .user_info {
    width: 100%;
    height: 28.533vw;
    border-radius: 3.2vw;
    background-color: #fff;
    .ipt {
      width: 74.133vw;
      height: 50%;
      padding: 0 6.933vw;
      display: flex;
      align-items: center;
      border-bottom: solid 0.267vw #ced3e0;
      div {
        width: 69.333vw;
        color: #ced3e0;
        font-size: 4.8vw;
        font-family: PingFangSC-Regular;
        line-height: 6.667vw;
      }
      .value {
        width: 69.333vw;
        color: #0a2463;
        font-weight: 600;
        font-size: 4.8vw;
        font-family: PingFangSC-Regular;
        line-height: 6.667vw;
      }
      img {
        width: 3.2vw;
        height: 3.2vw;
      }
    }
    .user_card {
      width: 74.133vw;
      height: 50%;
      padding: 0 6.933vw;
      display: flex;
      align-items: center;
      text-align: left;
      input {
        width: 100%;
        border: none;
        font-size: 4.8vw;
        font-family: PingFangSC-Regular;
        line-height: 6.667vw;
        // font-weight: 600;
        padding: 0;
        color: #0a2463;
        &::placeholder {
          color: #ced3e0;
          font-size: 4.8vw;
          font-family: PingFangSC-Regular;
          line-height: 6.667vw;
        }
      }
    }
  }
  .bot {
    display: flex;
    width: 33.333vw;
    margin: 0 auto;
    justify-content: center;
    margin-top: 5.333vw;
    font-size: 4.8vw;
    color: rgba(255, 255, 255, 1);
    font-family: PingFangSC-Regular;
    line-height: 6.667vw;
    img {
      width: 6.4vw;
      height: 6.4vw;
      margin-right: 0.8vw;
    }
  }
}
</style>